const router = {
    renderView() {
        let hash = location.hash?location.hash:'#home'; 
        console.log(hash)
        switch(hash){
            case '#home':
                $("main").html('home')
                break;
            case '#group':
                $("main").html('group')
                break;
            case '#cart':
                $("main").html('cart')
                break;
            case '#mine':
                $("main").html('mine')
                break;
        }
        $(`nav a[href='${hash}']`).closest('li').addClass('active').siblings().removeClass('active')
    },

    init(){
        window.addEventListener('load',this.renderView)
        window.addEventListener('hashchange',this.renderView)
    }
}

export {
    router
}